package org.scu.db.demo.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.scu.db.demo.model.Book;
import org.scu.db.demo.model.Title;

import java.util.List;
import java.util.Map;

@Mapper
public interface BookMapper {
    List<Book> queryBook();
    List<Map> query_call_and_count();

    @Select(value = "select book_id from book where BorrowerMemNo is not null")
    List<Integer> findAllBorrowedBooksId();

    @Select(value = "select * from title where name in ('Iliad','Odyssey')")
    List<Title> findIliadOrOdysseyTitle();

    @Select(value = "select count(*) from book where CallNumber like 'Call123'")
    Integer countCall123Book();

    @Select(value = "select CallNumber from Book\n" +
            "group by CallNumber\n" +
            "having count(*)<=2")
    List<String> findCountNotExceed2Callnumber();
}
